#include "camera.h"

Camera* Camera::Build(
  const Intrinsics& intrinsics,
  ImageLoader* image_loader,
  ImageWriter* image_writer) 
{
  if (image_loader)
  if (image_loader->width() != intrinsics.width
    || image_loader->height() != intrinsics.height)
  {
    std::cerr << "[ERROR] Camera::Build | "
      << "image_loader width | height != intrinsics width | height"
      << std::endl;
    return nullptr;
  }

  if (image_writer)
  if (image_writer->width() != intrinsics.width
    || image_writer->height() != intrinsics.height)
  {
    std::cerr << "[ERROR] Camera::Build | "
      << "image_writer width | height != intrinsics width | height"
      << std::endl;
    return nullptr;
  }

  auto cam = new Camera;
  cam->image_loader_.reset(image_loader);
  cam->image_writer_.reset(image_writer);
  cam->intrinsics_ = intrinsics;
  return cam;
}